package com.tool.PanelDisplay;

import java.awt.Color;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

import org.come.Frame.TestPetJframe1;
import org.come.Jpanel.TestPetJpanel1;
import org.come.bean.ConfigureBean;
import org.come.entity.RoleSummoning;
import org.come.model.Configure;
import org.come.mouslisten.PetAddPointMouslisten1;
import org.come.until.AnalysisString;
import org.come.until.FormsManagement;
import org.come.until.Music;
import org.come.until.UserMessUntil;

import com.tool.role.RoleData;

/**
 * @author 郑吉利
 * @date : 2017年11月23日 下午2:19:31
 */

// 点击召唤兽监听
public class PetPanelShow1 implements MouseListener {
    public static void Show() {
        ConfigureBean allConfigure = UserMessUntil.getConfigureBean();
        Map<BigDecimal, Configure> item = allConfigure.getAllConfigure();
        Configure configure = item.get(new BigDecimal(1));
        int ndsl = 4;
        if(configure.getNdslsx()!=null) {
            ndsl = Integer.parseInt(configure.getNdslsx());
        }
        // 将召唤兽信息放入到列表中
        List<RoleSummoning> pets = UserMessUntil.getPetListTable();
        TestPetJpanel1.showListModel(pets, RoleData.getRoleData().getLoginResult().getSummoning_id());
        for (int i = 0; i < ndsl; i++) {
            TestPetJpanel1.getLabNedan()[i].setGoodstable(null);
            TestPetJframe1.getTestPetJframe1().getTestPetJpanel1().remove(TestPetJpanel1.getLabNedan()[i]);
        }
        // 如果已经携带了召唤兽,那么打开面板的时候默认就打开所有的选中的信息
        if (pets.size() != 0) {
            UserMessUntil.setChosePetMes( UserMessUntil.getPetRgid(RoleData.getRoleData().getLoginResult().getSummoning_id()));
            ShowMesForJpanel1();
        }
        if (!FormsManagement.getframe(666).isVisible()) {
            FormsManagement.showForm(666);
            Music.addyinxiao("开关窗口.mp3");// 打开面板
        } else {
            FormsManagement.HideForm(666);
            Music.addyinxiao("关闭窗口.mp3");
        }
    }

    @Override
    public void mouseClicked(MouseEvent e) {

    }

    @Override
    public void mousePressed(MouseEvent e) {
        // TODO Auto-generated method stub
        Show();
    }

    @Override
    public void mouseReleased(MouseEvent e) {
        // TODO Auto-generated method stub

    }

    @Override
    public void mouseEntered(MouseEvent e) {
        // TODO Auto-generated method stub

    }

    @Override
    public void mouseExited(MouseEvent e) {
        // TODO Auto-generated method stub

    }

    public static void ShowMesForJpanel1() {
        PetAddPointMouslisten1.showPetValue(true);
    }

    /**
     * 将选中的召唤兽信息展示在面板信息里面
     */
    public static void ShowMesForJpanel1(boolean showHead) {
        // 进行面板展示
        PetAddPointMouslisten1.showPetValue(showHead);
    }

    /**
     * 召唤兽等级的展示
     */
    public static void changeGrade(int grade, String name) {

        // 判断召唤兽的等级
        if (grade <= 100) {

            TestPetJpanel1.getLablevel().setForeground(new Color(0, 255, 0));
            TestPetJpanel1.getLablevel().setText("0转" + grade + "级");
            TestPetJpanel1.getLabname().setText(name);

        } else if (grade > 100 && grade <= 221) {

            TestPetJpanel1.getLablevel().setForeground(new Color(255, 140, 0));
            TestPetJpanel1.getLablevel().setText("1转" + (grade - 101) + "级");
            TestPetJpanel1.getLabname().setText(name);

        } else if (grade > 221 && grade <= 362) {

            TestPetJpanel1.getLablevel().setForeground(new Color(0, 245, 255));
            TestPetJpanel1.getLablevel().setText("2转" + (grade - 222) + "级");
            TestPetJpanel1.getLabname().setText(name);

        } else if (grade > 362 && grade <= 543) {

            TestPetJpanel1.getLablevel().setForeground(new Color(238, 44, 44));
            TestPetJpanel1.getLablevel().setText("3转" + (grade - 363) + "级");
            TestPetJpanel1.getLabname().setText(name);

        } else {
            TestPetJpanel1.getLablevel().setForeground(new Color(138,43,226));
            TestPetJpanel1.getLablevel().setText("点化" + (grade - 544) + "级");
            TestPetJpanel1.getLabname().setText(name);
        }
        // 根据是否飞升提供不同的面板
        TestPetJpanel1.getTestPetJpanel1().changeSoaringPanel(AnalysisString.petTurnRount(grade));
    }
}
